import '../apis/resquest/http.dart';
import '../controller/notice_ctrl/notice_ctrl.dart';
import '../model/bean/notice_bean.dart';
//import '../model/bean/unread_msg.dart';

class Notice {
  /// 查询未读消息条数（首页使用）
  /// * [data] Map|请求参数|必填
  static queryUnreadMsg() async {
    const url = '/elevator-maintenance-app/message/numberOfMessages';
    try {
      HttpResponse _r = await Http.getInstance().get(url);
      return NoticeCtrl.fromJson(_r.data);
    } catch (e) {}
  }

  /// 查询消息列表
  /// * [data] Map|请求参数|必填
  static queryListMsg(Map<String, dynamic> data) async {
    const url = '/elevator-maintenance-app/message/getMessages';
    try {
      HttpResponse _r = await Http.getInstance().get(url, params: data);
      return NoticeListBean.fromJson(_r.data);
    } catch (e) {}
  }

  /// 设置消息状态
  /// * [data] Map|请求参数|选填
  static changeNoticeStatus({Map<String, dynamic> data}) async {
    const url = '/elevator-maintenance-app/message/changeStatus';
    try {
      HttpResponse _r = await Http.getInstance().post(url, params: data);
      return _r.data;
    } catch (e) {
      throw e;
    }
  }
}
